package com.sgb.kjwl.pop;

import android.content.Context;

import androidx.recyclerview.widget.GridLayoutManager;

import com.sgb.kjwl.R;
import com.swgk.core.util.PickSelectEntity;
import com.sgb.kjwl.view.ui.adapter.home.HomeEnterpriseEncyclopediaListAdapter;
import com.sgb.kjwl.view.widget.MaxHeightRecyclerView;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import java.util.List;

public class HomeEnterpriseEncyclopediaTypePopWindow extends BasePopWindow {

    private HomeEnterpriseEncyclopediaListAdapter homeEnterpriseEncyclopediaListAdapter;

    public HomeEnterpriseEncyclopediaTypePopWindow(Context context) {
        super(context);
    }

    @Override
    protected int popLayout() {
        return R.layout.popwindow_goods_types;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        MaxHeightRecyclerView recyclerView = holder.getPop().findViewById(R.id.type_list);
        homeEnterpriseEncyclopediaListAdapter = new HomeEnterpriseEncyclopediaListAdapter(mContext, null);
        homeEnterpriseEncyclopediaListAdapter.setItemSelect(true);
        homeEnterpriseEncyclopediaListAdapter.setDefItem(-1);
        recyclerView.setLayoutManager(new GridLayoutManager(mContext, 4));
        recyclerView.setAdapter(homeEnterpriseEncyclopediaListAdapter);
        homeEnterpriseEncyclopediaListAdapter.setOnItemClick(new AdapterOnItemClick<PickSelectEntity>() {
            @Override
            public void onItemClick(PickSelectEntity provinceEntity, int position) {
                onResultClick.result(provinceEntity, position, null);
                dissMiss();
            }
        });
    }

    public void setData(List<PickSelectEntity> dictdata) {
        homeEnterpriseEncyclopediaListAdapter.setDatas(dictdata);
    }

    public void setDefItem(int position) {
        homeEnterpriseEncyclopediaListAdapter.setDefItem(position);
    }
}
